package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Delete;

import com.neusoft.elmboot.po.Token;

@Mapper
public interface TokenMapper {

	@Select("select * from token where tokenId=#{tokenId} and userId=#{userId}")
	public Token getTokenById(Token token);
	
	@Select("select count(*) from token where tokenId=#{tokenId}")
	public int getToken(String tokenId);
	
	@Insert("insert into token values(#{tokenId},#{fromtPublicKey},null,#{time})")
	public int saveToken(Token token);
	
	@Update("update token set userId=#{userId} where tokenId=#{tokenId}")
	public int updateToken(Token token);
	
	@Delete("delete from token where time=#{time}")
	public int deleteToken(Token token);
}
